home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ANSIVIEW.ZIP / ANSITEST.PAS next >
Pascal/Delphi Source File  |  1991-01-30  |  6KB  |  196 lines

  1.  
  2. { DEFINE TVSPY}  {Define this if you want the TVSPY program installed}
  3.  
  4. Program ANSI_Test;
  5.  
  6. Uses  Dos, App, Objects, Menus, Drivers, Views, Gadgets, Memory,
  7. {$IFDEF TVSPY}
  8.       HeapWin, EventWin,
  9. {$ENDIF}
  10.       AnsiView;
  11.  
  12. CONST MaxScreen  = 100;
  13.  
  14. TYPE  PMyWindow = ^TMyWindow;
  15.       TMyWindow = OBJECT(TANSIView)
  16.                      Count : BYTE;
  17.                      CONSTRUCTOR Init;
  18.                      PROCEDURE HandleEvent(VAR Event : TEvent); VIRTUAL;
  19.                   END;
  20.  
  21.       PMyApp    = ^TMyApp;
  22.       TMyApp    = OBJECT(TApplication)
  23.                      Clock : PClockView;
  24.                      Heap  : PHeapView;
  25.                      CONSTRUCTOR Init;
  26.                      PROCEDURE HandleEvent(VAR Event : TEvent); VIRTUAL;
  27.                      PROCEDURE GetEvent(VAR E : TEvent); VIRTUAL;
  28.                      PROCEDURE InitStatusLine; VIRTUAL;
  29.                      PROCEDURE InitMenuBar; VIRTUAL;
  30.                      PROCEDURE Idle; VIRTUAL;
  31.                      PROCEDURE NewWindow;
  32.                   END;
  33.  
  34. VAR   MyApp : TMyApp;
  35.  
  36. CONST cmNewWin  = 100;
  37.       cmWriteLN = 101;
  38.       cmGotoXY  = 102;
  39.       cmRandom  = 103;
  40.       cmWacka   = 104;
  41.  
  42. CONSTRUCTOR TMyWindow.Init;
  43. VAR   R : TRect;
  44.       L : TPoint;
  45.       X : BYTE;
  46.       Y : BYTE;
  47. BEGIN
  48.    X := RANDOM(30);
  49.    Y := RANDOM(10);
  50.    R.Assign(X,Y,X + 50,Y + 10);
  51.    L.X := 80;
  52.    L.Y := 25;
  53.    TANSIView.Init(R,L,'Test Window',0);
  54.    Count := 0;
  55. END;
  56.  
  57. PROCEDURE TMyWindow.HandleEvent;
  58. VAR   i : INTEGER;
  59. BEGIN
  60.    TANSIView.HandleEvent(Event);
  61.    CASE Event.What OF
  62.       evCommand : CASE Event.Command OF
  63.                      cmWriteLN : PrintLN('Another fine mess you found');
  64.                      cmGotoXY  : GotoXY(RANDOM(Interior^.MaxDim.X),RANDOM(Interior^.MaxDim.Y));
  65.                      cmRandom  : FOR i := 1 TO 500 DO
  66.                                     PrintChar(CHAR(RANDOM(96) + 32));
  67.                      cmWacka   : BEGIN
  68.                                     ClrScr;
  69.                                     FOR i := 1 TO 8 DO
  70.                                        Print('1234567890');
  71.                                     PrintLN('Another fine test of the system');
  72.                                     PrintLN('This is going to test some insertion');
  73.                                     PrintLN('and deletion commands...');
  74.                                     GotoXY(8,1);
  75.                                     print(#27 + '[6P');
  76.                                     GotoXY(8,2);
  77.                                     print(#27 + '[6@');
  78.                                     GotoXY(1,6);
  79.                                     PrintLN('Finished...')
  80.                                  END;
  81.                      ELSE EXIT
  82.                   END;
  83.       ELSE EXIT
  84.    END;
  85.    ClearEvent(Event)
  86. END;
  87.  
  88. CONSTRUCTOR TMyApp.Init;
  89. VAR   R : TRect;
  90. BEGIN
  91.    TApplication.Init;
  92.  
  93.    RegisterANSIView;
  94.  
  95.    GetExtent(R);
  96.    R.A.X := R.B.X - 9;
  97.    R.B.Y := R.A.Y + 1;
  98.    Clock := NEW(PClockView,Init(R));
  99.    Insert(Clock);
  100.  
  101.    GetExtent(R);
  102.    Dec(R.B.X);
  103.    R.A.X := R.B.X - 9;
  104.    R.A.Y := R.B.Y - 1;
  105.    Heap := NEW(PHeapView,Init(R));
  106.    Insert(Heap);
  107.  
  108. {$IFDEF TVSPY}
  109.    Desktop^.GetExtent(R);
  110.    R.Assign(R.A.X,R.B.Y-10,R.B.X div 2,R.B.Y);
  111.    EventWindow := NEW(PEventWindow,Init(R,'Event Window',wnNoNumber,100));
  112.    Desktop^.Insert(EventWindow);
  113.    EventWindow^.InsertCommand(cmNewWin,'cmNewWin');
  114.    EventWindow^.InsertCommand(cmWriteLN,'cmWriteLN');
  115.    EventWindow^.InsertCommand(cmGotoXY,'cmGotoXY');
  116.    EventWindow^.InsertCommand(cmRandom,'cmRandom');
  117.    EventWindow^.InsertCommand(cmWacka,'cmWacka');
  118. {$ENDIF}
  119. END;
  120.  
  121. PROCEDURE TMyApp.HandleEvent;
  122. BEGIN
  123.    TApplication.HandleEvent(Event);
  124.    CASE Event.What OF
  125.       evCommand : CASE Event.Command OF
  126.                      cmNewWin : NewWindow;
  127.                      ELSE EXIT
  128.                   END;
  129.       ELSE EXIT
  130.    END;
  131.    ClearEvent(Event)
  132. END;
  133.  
  134. PROCEDURE TMyApp.Idle;
  135. BEGIN
  136.    TApplication.Idle;
  137.    Clock^.Update;
  138.    Heap^.Update;
  139. END;
  140.  
  141. PROCEDURE TMyApp.GetEvent;
  142. BEGIN
  143.    TApplication.GetEvent(E);
  144. {$IFDEF TVSPY}
  145.    EventWindow^.DisplayEvent(E);
  146. {$ENDIF}
  147. END;
  148.  
  149. PROCEDURE TMyApp.InitStatusLine;
  150. VAR   R : TRect;
  151. BEGIN
  152.    GetExtent(R);
  153.    R.A.Y := R.B.Y - 1;
  154.    StatusLine := NEW(PStatusLine,Init(R,
  155.                    NewStatusDef(0,$FFFF,
  156.                      NewStatusKey('~Alt-X~ Exit',kbAltX,cmQuit,
  157.                      NewStatusKey('~Alt-F3~ Close',kbAltF3,cmClose,
  158.                      NIL)),
  159.                    NIL)
  160.                  ))
  161. END;
  162.  
  163. PROCEDURE TMyApp.InitMenuBar;
  164. VAR   R : TRect;
  165. BEGIN
  166.    GetExtent(R);
  167.    R.B.Y := R.A.Y + 1;
  168.    MenuBar := NEW(PMenuBar,Init(R,NewMenu(
  169.                 NewSubMenu('~F~ile',hcNoContext,NewMenu(
  170.                   NewItem('~O~pen','F3',kbF3,cmNewWin,hcNoContext,
  171.                   NewItem('~Q~uit','Alt-X',kbAltX,cmQuit,hcNoContext,
  172.                   NIL))),
  173.                 NewSubMenu('~V~irtual',hcNoContext,NewMenu(
  174.                   NewItem('~W~riteLN','',kbNoKey,cmWriteLN,hcNoContext,
  175.                   NewItem('~G~otoXY','',kbNoKey,cmGotoXY,hcNoContext,
  176.                   NewItem('~R~andom','',kbNoKey,cmRandom,hcNoContext,
  177.                   NewItem('W~a~cka','',kbNoKey,cmWacka,hcNoContext,
  178.                   NIL))))),
  179.                 NIL))
  180.               )))
  181. END;
  182.  
  183. PROCEDURE TMyApp.NewWindow;
  184. VAR   PPtr : PMyWindow;
  185. BEGIN
  186.    PPtr := NEW(PMyWindow,Init);
  187.    IF PPtr <> NIL THEN
  188.       DeskTop^.Insert(PPtr);
  189. END;
  190.  
  191. BEGIN
  192.    MyApp.Init;
  193.    MyApp.Run;
  194.    MyApp.Done
  195. END.
  196.